package cn.cdeden.aiqa.mapper;

import cn.cdeden.aiqa.domain.WikiRecord;
import cn.cdeden.aiqa.domain.vo.WikiRecordVo;
import cn.cdeden.common.mybatis.core.mapper.BaseMapperPlus;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * AI提问记录Mapper接口
 *
 * @author Nick
 * @date 2024-12-12
 */
public interface WikiRecordMapper extends BaseMapperPlus<WikiRecord, WikiRecordVo> {

    @Select("SELECT wr.id, wr.title, wr.conversation_id, wr.app_id, wr.re_count, wr.record, wr.user_id, wr.assistant_id, " +
        "wa.app_name, wa.app_key, wr.create_by, wr.create_time, wr.update_by, wr.update_time,su.nick_name FROM wiki_record wr " +
        "LEFT JOIN wiki_app wa ON wr.app_id = wa.id " +
        "LEFT JOIN sys_user su ON wr.user_id = su.user_id " +
        " ${ew.customSqlSegment} ORDER BY wr.create_time DESC")
    Page<WikiRecordVo> selectVoPageWithAppInfo(Page<?> page, @Param("ew") Wrapper<WikiRecord> queryWrapper);

}
